(async () => {
  const mongoose = require('mongoose');
  try {
    //连接数据库
    await mongoose.connect('mongodb://127.0.0.1:27017/xiaohigh');
    //模型对象
    const CarSchema = mongoose.Schema({
      brand: String,
      price: Number,
      color: String
    });
    const CarModel = mongoose.model('car', CarSchema);
    //文档插入
    // let car = await CarModel.create({
    //   brand: '比亚迪',
    //   price: 290000,
    //   color: '黑色'
    // });

    //文档读取
    let cars = await CarModel.find();
    console.log(cars);
  } catch (e) {
    console.log('连接失败~~');
  }
})()